package com.itheima.config;

import com.itheima.pojo.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {
    //处理哪些异常？
    @ExceptionHandler(Exception.class)
    //如何处理？
    public Result ex(Exception e){
        e.printStackTrace();//打印异常
        return Result.error(e.getMessage());
    }
}
